package com.stt.weather.base.controller;

import com.stt.weather.model.WeatherData;
import com.stt.weather.base.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 天气数据控制器
 * 提供天气数据的REST API接口
 */
@RestController
@RequestMapping("/api/weather")
public class WeatherController {

    /**
     * 天气服务对象
     */
    @Autowired
    private WeatherService weatherService;

    /**
     * 获取指定城市的天气数据
     * 
     * @param cityCode 城市编码
     * @return 天气数据对象
     */
    @GetMapping("/{cityName}")
    public WeatherData getWeatherData(@PathVariable String cityCode) {
        WeatherData weatherData = weatherService.getWeatherData(cityCode);
        // 发送通知
        weatherService.sendEmailNotification(weatherData);
        weatherService.sendSMSNotification(weatherData);
        return weatherData;
    }
} 